package net.m510.autosurfer.smbcvisa;

import java.net.URI;
import java.util.List;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentPostProcess;
import net.m510.autosurfer.core.Parameters;

import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

public class SmbcVisaLogin extends DocumentPostProcess {
	private static final Logger log = Logger.getLogger(SmbcVisaLogin.class.getName());
	private String userId;
	private String password;

	public SmbcVisaLogin() {
		this(null,null);
	}
	public SmbcVisaLogin(CloseableHttpClient client, HttpClientContext context) {
		super(client, context);
		super.log = log;
	}
	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		Parameters p = Parameters.create(form);
		p.put("userid", this.userId);
		p.put("password", this.password);
		p.put("login01", "");
		return p.asNameValueList();
	}

	@Override
	protected URI getUri(Document doc) {
		return URI.create("https://www.smbc-card.com/vp/xt_login.do?strURL=https%3A%2F%2Fwww%2Esmbc-card%2Ecom%2Fmem%2Ftop%2Findex%2Ejsp");
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
}